package com.example.yiwei.crm.view.frament.JDCoorFragment;


import android.content.DialogInterface;
import android.content.Intent;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v4.app.Fragment;
import android.support.v7.app.AlertDialog;
import android.support.v7.view.ContextThemeWrapper;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.AdapterView;

import com.example.yiwei.crm.R;
import com.example.yiwei.crm.readcard.MainActivitycard;
import com.example.yiwei.crm.view.Class.gridViewClass.MyGridView;
import com.example.yiwei.crm.view.Class.gridViewClass.QuertGridAdapter;
import com.example.yiwei.crm.view.activity.JYCoordingActivity.AddCoorActivity;
import com.example.yiwei.crm.view.activity.JYCoordingActivity.AddCoorCustomerActivity;
import com.example.yiwei.crm.view.activity.JYCoordingActivity.JYAddApoActivity;
import com.example.yiwei.crm.view.activity.JYCoordingActivity.JYAddJLActivity;
import com.example.yiwei.crm.view.activity.JYCoordingActivity.JYAddVisitActivity;
import com.example.yiwei.crm.view.activity.JYCoordingActivity.JYApoJLActivity;
import com.example.yiwei.crm.view.activity.JYCoordingActivity.JYSearchSHActivity;
import com.example.yiwei.crm.view.activity.JYCoordingActivity.JYjdActivity;
import com.example.yiwei.crm.view.activity.JYCoordingActivity.UseCarActivity;


/**
 * A simple {@link Fragment} subclass.
 */
public class EnteringFragment extends Fragment {
    private MyGridView gridview;
    @Override
    public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
        View rootview=inflater.inflate(R.layout.frament_luru,container,false);
        gridview=(MyGridView)rootview.findViewById(R.id.gridview);
        gridview.setAdapter(new QuertGridAdapter(getActivity()));
        gridview.setOnItemClickListener(new AdapterView.OnItemClickListener() {
            @Override
            public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
                if (position==0){
                    //新增合作伙伴
                    Intent intent = new Intent(getActivity(), AddCoorActivity.class);
                    startActivity(intent);
                }
                if (position==1){
                    //新增拜访
                    Intent intent = new Intent(getActivity(), JYAddVisitActivity.class);
                    startActivity(intent);
                }
                if (position==2){
                    //新增交流
                    Intent intent = new Intent(getActivity(), JYAddJLActivity.class);
                    startActivity(intent);
                }
                if (position==3){
                    AlertDialog.Builder builder;
                    builder = new AlertDialog.Builder(new ContextThemeWrapper(getActivity(), R.style.custom_dialog));
                    builder.setTitle("请选择信息录入方式");
                    builder.setPositiveButton("手动输入", new DialogInterface.OnClickListener() {
                        @Override
                        public void onClick(DialogInterface dialog, int which) {
                            Intent intent = new Intent(getActivity(), AddCoorCustomerActivity.class);
                            startActivity(intent);
                        }
                    });
                    builder.setNegativeButton("仪器扫描", new DialogInterface.OnClickListener() {
                        @Override
                        public void onClick(DialogInterface dialog, int which) {
                            Intent intent = new Intent(getActivity(), MainActivitycard.class);
                            intent.putExtra("tag","cc");
                            startActivity(intent);
                        }
                    });
                    builder.show();
                    //新增患者

                }
                if (position==4){
                    //新增预约
                    Intent intent = new Intent(getActivity(), JYAddApoActivity.class);
                    startActivity(intent);
                }
                if (position==5){
                    //新增满意度
                    Intent intent = new Intent(getActivity(), JYjdActivity.class);
                    startActivity(intent);
                }
                if (position == 6){
                    //申请用车
                    Intent intent = new Intent(getActivity(), UseCarActivity.class);
                    startActivity(intent);
                }
            }
        });
        return rootview;
    }

}
